import axios from 'axios'
import apiUrls from 'common/api-urls'
import { contentTypeWww } from 'common/axio-decorate'

export function getCourseUserList(data) {
  return axios.get(apiUrls.getCourseUserList, {
    params: data
  })
}

export function getEmployeeEmpPart(data) {
  return axios.post(apiUrls.getEmployee, {
    ...data
  })
}

export function addCourseUser(data) {
  return axios.post(apiUrls.addCourseUser, {
    ...data
  })
}

export function getCourseStuGroup(data) {
  return axios.get(apiUrls.getCourseStuGroup, {
    params: data
  })
}

export function addCourseStuGroup(data) {
  return axios.post(apiUrls.addCourseStuGroup, {
    ...data
  })
}

export function updateCourseStuGroup(data) {
  return axios.post(apiUrls.updateCourseStuGroup, {
    ...data
  })
}

export function deleteCourseStuGroup(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.delete(`${apiUrls.deleteCourseStuGroup}?id=${data.id}`)
}

export function deleteCourseUser(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.delete(`${apiUrls.deleteCourseUser}?id=${data.id}`)
}

export function getCourseCheckUser(data) {
  return axios.get(apiUrls.getCourseCheckUser, {
    params: data
  })
}

export function batchReviewCourseUser(data) {
  return axios.post(apiUrls.batchReviewCourseUser, {
    ...data
  })
}

export function importCourseCheckExcel(data) {
  const formData = new FormData()
  formData.append('file', data.file.raw)
  if (data.courseId) {
    formData.append('courseId', data.courseId)
  }
  return axios.post(apiUrls.importCourseCheckExcel, formData)
}

export function importCourseSaveExcel(data) {
  const formData = new FormData()
  formData.append('file', data.file.raw)
  if (data.courseId) {
    formData.append('courseId', data.courseId)
  }
  return axios.post(apiUrls.importCourseSaveExcel, formData)
}

export function getCourseUserLabels(data) {
  return axios.post(apiUrls.getCourseUserLabels, {
    ...data
  })
}

export function courseSelfGroup(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.post(apiUrls.courseSelfGroup, data, {
    headers: { 'Content-Type': contentTypeWww }
  })
}

export function courseCheckReview(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.post(apiUrls.courseCheckReview, data, {
    headers: { 'Content-Type': contentTypeWww }
  })
}

export function getCourseNoGroupUser(data) {
  return axios.get(apiUrls.getCourseNoGroupUser, {
    params: data
  })
}

export function setCourseGroupUser(data) {
  return axios.post(apiUrls.setCourseGroupUser, {
    ...data
  })
}
